clc;
close all;

%chargement des images
image = imread('lena.pgm');
noisy = imread('lenabruitee.pgm');

%tranformee de Fourier et centrage
image_tf = fftshift(fft2(double(image)));
noisy_tf = fftshift(fft2(double(noisy)));

%module
image_mod = log(1+abs(image_tf));
noisy_mod = log(1+abs(noisy_tf));

%chargement du masque
MasqueStruct = load('masque.mat');
masque = MasqueStruct.F_m;

%filtrage de notre image
noisy_filtered = noisy_tf .* masque;

%decentrage et transformee de Fourier inverse
noisy_ift = ifft2(ifftshift(double(noisy_filtered)));

%colormap('gray');

subplot(331);
imshow(image);
title('Lena');

subplot(332);
imshow(noisy);
title('Lena bruitee');

subplot(336);
imshow(masque);
title('Masque');

subplot(334);
imagesc(image_mod);
title('Spectre Lena');

subplot(335);
imagesc(noisy_mod);
title('Spectre Lena bruitee');

subplot(337);
imagesc(angle(noisy_filtered));
title('Masquage du spectre');

subplot(338);
imagesc(noisy_ift);
title('Lena debruitee');

